revPrintText
Type
command
Summary
Prints formatted or unformatted text.
Syntax
revPrintText <textToPrint> [, <headerText> [, <footerText> [, <fieldTemplate>]]]
Description
Use the revPrintText command to print any text from within a handler.
The revPrintText command does not accept direct field references for the fieldTemplate parameter. For example, the following statement causes an error message:
revPrintText myText,,,field \"Text\" -- CAN\'T USE THIS FORM
Instead, use a form that evaluates to a field reference, like this:
revPrintText myText,,,the name of field \"Text\" -- use this form
revPrintText myText,,,(\"field\" && quote & \"Text\" & quote) -- or this
The revPrintText command can be used to print either formatted text (via the htmlText property's format) or plain text. If you are generating formatted text, see the htmlText property for a description of the differences between the htmlText property's formatting and standard HTML.
If the textToPrint, headerText, or footerText contains <p> or a start/end tag pair, the revPrintText command assumes the text is in the same format as the htmlText property. Otherwise, the revPrintText command assumes the text is plain text.
If the text being printed is plain text, and a fieldTemplate is specified, the text is printed with that field's textFont, textSize, and textStyle. Otherwise, the text is printed in plain 12-point, with the default font of the platform being used. (The field specified in the fieldTemplate does not need to contain any text; only its appearance properties are used, not its contents. If you want to print the contents of the field, use the revPrintField command instead.)
If the textToPrint, headerText, or footerText contains any expressions of the form <%expression%>, the expression is evaluated and replaced with the value before the text is printed. For example, if the textToPrint contains the text Today's date is <%the long date%> the printed text reads Today's date is Friday, February 15, 2002 (assuming, of course, that the revPrintText command is executed on that date).
You can also use the special values <%pageNumber%> and <%numPages%> in the textToPrint, headerText, or footerText. These expressions are replaced with the current page number or total number of pages respectively.
The headerText and footerText can contain up to two tab characters:
- Everything up to the first tab character is left-aligned.
- Everything between the first and second tab characters is centered.
- Everything after the second tab character is right-aligned.
If the headerText or footerText contain more than two tab characters, everything after the third tab is ignored.
To show the standard print dialog box, use the revShowPrintDialog command before the revPrintText command.
If the textToPrint contains tags, the tags are interpreted as text style information. To print tags literally, set the text of a field to the text you want to print, then use the HTMLText of that field as the textToPrint. Converting to the HTMLText escapes the tags and allows them to be printed.
The revPrintText command is part of the Printing library. To ensure that the command works in a standalone application, you must include this custom library when you create your standalone. In the Inclusions pane of the Standalone Application Settings window, make sure the "Printing" library checkbox is checked.
Parameters
Name | Type | Description |
---|---|---|
textToPrint | string | |
headerText | string | If the headerText is empty, no page header is printed. |
footerText | string | If the footerText is empty, no page footer is printed. |
fieldTemplate | Any expression that evaluates to a field reference. |
Examples
revPrintText "Hello world"
revPrintText myCollectedData,"Confidential" -- header with no footer
revPrintText (the htmlText of field "Info"),"Info",the time && the date
revPrintText field 1,,"prepared by John Smith" -- footer, no header
revPrintText it,tab & myTitle -- centered header
revPrintText thisText,,,the long name of field "Text"
Related
keyword: field
library: Printing library, library
message: startup, openBackground, preOpenStack, openStack, preOpenCard
object: field
property: textStyle, properties, HTMLText, textFont, textSize
command: revPrintReport, answer printer, revPrintField
function: platform
glossary: LiveCode custom library, application, standalone application, evaluate, property, text, execute, HTML, command, object reference, expression, main stack, group, Standalone Application Settings, message, parameter, statement, handler
Compatibility and Support
Introduced
LiveCode 1.0
OS
mac
windows
linux
Platforms
desktop